package com.jvm.coline.part4.dispatch;

/**
 * @author Coline
 * 静态分派
 */
public class StaticDispatch {
    static abstract class Human{}
    static class Man extends Human{}
    static class Woman extends Human{}

    public void sayHello(Human human){
        System.out.println("Human say Hello");
    }

    public void sayHello(Man man){
        System.out.println("man say Hello");
    }

    public void sayHello(Woman woman){
        System.out.println("woman say Hello");
    }

    public static void main(String[] arg0){
        Human human1 = new Man();
        Human human2 = new Woman();

        StaticDispatch staticDispatch = new StaticDispatch();
        staticDispatch.sayHello(human1);
        staticDispatch.sayHello(human2);

        staticDispatch.sayHello((Man) human1);
        staticDispatch.sayHello((Woman) human2);
    }
}
